Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

added database config to drizzle.config in app container

Type of Change

  • Bug fix

Testing

Manually.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Oct 3, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
sim Building Building Preview Comment Oct 3, 2025 1:09am
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Oct 3, 2025 1:09am

@waleedlatif1 waleedlatif1 merged commit 62298bf into staging Oct 3, 2025
4 of 5 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/d branch October 3, 2025 01:09
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Summary

This PR adds SSL configuration support to the Drizzle database configuration in the app container (`apps/sim/drizzle.config.ts`). The implementation introduces a `getSSLConfig()` function that handles various SSL connection modes including disable, prefer, require, verify-ca, and verify-full, with support for custom CA certificates via base64 encoded environment variables. This brings the app container's database configuration in line with the existing SSL handling found in the packages database configuration.

The change also updates the schema and output directory paths to reference the centralized database package (../../packages/db/schema.ts and ../../packages/db/migrations) rather than local paths, indicating a move toward centralizing database configuration management. This ensures consistency across the codebase and eliminates duplication of database schema definitions.

The SSL configuration logic reads from DATABASE_SSL and DATABASE_SSL_CA environment variables, providing flexible deployment options for different environments - from local development (SSL disabled) to production environments requiring strict SSL verification with custom certificates.

Changed Files
Filename Score Overview
apps/sim/drizzle.config.ts 4/5 Added SSL configuration function and updated paths to use centralized database package

Confidence score: 4/5

  • This PR is safe to merge with minimal risk as it adds defensive SSL configuration handling
  • Score reflects solid implementation following existing patterns with proper error handling and type safety
  • Pay attention to environment variable setup in deployment environments to ensure SSL configuration works correctly

Sequence Diagram

sequenceDiagram
    participant User
    participant "Drizzle CLI" as CLI
    participant "drizzle.config.ts" as Config
    participant "Environment" as Env
    participant "SSL Config" as SSL
    participant "Database" as DB

    User->>CLI: "Run drizzle migration/push command"
    CLI->>Config: "Load configuration"
    Config->>Env: "Import env from './lib/env'"
    Config->>SSL: "Call getSSLConfig()"
    SSL->>Env: "Check env.DATABASE_SSL"
    alt SSL disabled or not set
        SSL-->>Config: "Return undefined"
    else SSL prefer
        SSL-->>Config: "Return 'prefer'"
    else SSL require
        SSL-->>Config: "Return {rejectUnauthorized: false}"
    else SSL verify-ca/verify-full
        SSL->>Env: "Check env.DATABASE_SSL_CA"
        alt CA certificate provided
            SSL->>SSL: "Decode base64 CA certificate"
            SSL-->>Config: "Return {rejectUnauthorized: true, ca: decodedCA}"
        else No CA certificate
            SSL-->>Config: "Return {rejectUnauthorized: true}"
        end
    end
    Config->>Config: "Build dbCredentials with URL and SSL config"
    Config-->>CLI: "Return complete configuration"
    CLI->>DB: "Connect using credentials with SSL settings"
    DB-->>CLI: "Connection established"
    CLI-->>User: "Command completed successfully"
Loading

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

return 'prefer' as const
}

const sslConfig: any = {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Using any type reduces type safety. Consider defining a proper SSL config interface.

Context Used: Context from dashboard - Avoid using type assertions to 'any' in TypeScript. Instead, ensure proper type definitions are used... (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/sim/drizzle.config.ts
Line: 15:15

Comment:
**style:** Using `any` type reduces type safety. Consider defining a proper SSL config interface.

**Context Used:** Context from `dashboard` - Avoid using type assertions to 'any' in TypeScript. Instead, ensure proper type definitions are used... ([source](https://app.greptile.com/review/custom-context?memory=c63aedff-69e6-48d8-81cf-9763416ee01c))

How can I resolve this? If you propose a fix, please make it concise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants